package com.ruoyi.points.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.points.mapper.PointsChangeRecordMapper;
import com.ruoyi.points.domain.PointsChangeRecord;
import com.ruoyi.points.service.IPointsChangeRecordService;

/**
 * 积分变动记录Service业务层处理
 * 
 * @author 区嘉盛
 * @date 2025-06-17
 */
@Service
public class PointsChangeRecordServiceImpl implements IPointsChangeRecordService 
{
    @Autowired
    private PointsChangeRecordMapper pointsChangeRecordMapper;

    /**
     * 查询积分变动记录
     * 
     * @param id 积分变动记录主键
     * @return 积分变动记录
     */
    @Override
    public PointsChangeRecord selectPointsChangeRecordById(Long id)
    {
        return pointsChangeRecordMapper.selectPointsChangeRecordById(id);
    }

    /**
     * 查询积分变动记录列表
     * 
     * @param pointsChangeRecord 积分变动记录
     * @return 积分变动记录
     */
    @Override
    public List<PointsChangeRecord> selectPointsChangeRecordList(PointsChangeRecord pointsChangeRecord)
    {
        return pointsChangeRecordMapper.selectPointsChangeRecordList(pointsChangeRecord);
    }

    /**
     * 新增积分变动记录
     * 
     * @param pointsChangeRecord 积分变动记录
     * @return 结果
     */
    @Override
    public int insertPointsChangeRecord(PointsChangeRecord pointsChangeRecord)
    {
        return pointsChangeRecordMapper.insertPointsChangeRecord(pointsChangeRecord);
    }

    /**
     * 修改积分变动记录
     * 
     * @param pointsChangeRecord 积分变动记录
     * @return 结果
     */
    @Override
    public int updatePointsChangeRecord(PointsChangeRecord pointsChangeRecord)
    {
        return pointsChangeRecordMapper.updatePointsChangeRecord(pointsChangeRecord);
    }

    /**
     * 批量删除积分变动记录
     * 
     * @param ids 需要删除的积分变动记录主键
     * @return 结果
     */
    @Override
    public int deletePointsChangeRecordByIds(Long[] ids)
    {
        return pointsChangeRecordMapper.deletePointsChangeRecordByIds(ids);
    }

    /**
     * 删除积分变动记录信息
     * 
     * @param id 积分变动记录主键
     * @return 结果
     */
    @Override
    public int deletePointsChangeRecordById(Long id)
    {
        return pointsChangeRecordMapper.deletePointsChangeRecordById(id);
    }

    /**
     * 根据用户ID查询积分变动记录
     *
     * @param userId 用户ID
     * @param type 记录类型(1:全部 2:收入 3:支出)
     * @return 积分变动记录列表
     */
    @Override
    public List<PointsChangeRecord> getRecordByUserId(Long userId, Integer type) {
        if(type == 1){
            return pointsChangeRecordMapper.getRecordByUserId(userId);
        }else if(type == 2){
            return pointsChangeRecordMapper.getIncomeRecordByUserId(userId);
        }else {
            return pointsChangeRecordMapper.getExpendRecordByUserId(userId);
        }
    }
}
